import { defineStore } from 'pinia';
import { ref } from 'vue';

export interface Agent {
  id: string;
  name: string;
  identifier: string;
  modelUsage: 'fixed' | 'switchable';
  fixedModel?: string;
  streamOutput: boolean;
  backgroundPrompt: string;
  welcomeMessage: 'show' | 'hide';
  promptContent: string;
  scenePrompt: string;
  fileUpload: boolean;
  referencedFunctions: string[];
  recommendedPrompts: { name: string }[];
  vectorStores: {
    id: string;
    name: string;
    maxResults: number;
    similarityThreshold: number;
  }[];
  status: 'active' | 'inactive';
}

export const useAgentsStore = defineStore('agents', () => {
  const agents = ref<Agent[]>([]);

  const fetchAgents = async () => {
    // TODO: 实现从后端获取智能体列表
    return agents.value;
  };

  const createAgent = async (agent: Omit<Agent, 'id'>) => {
    // TODO: 实现创建智能体
    const newAgent = {
      ...agent,
      id: Date.now().toString()
    };
    agents.value.push(newAgent);
    return newAgent;
  };

  const updateAgent = async (agent: Agent) => {
    // TODO: 实现更新智能体
    const index = agents.value.findIndex(a => a.id === agent.id);
    if (index !== -1) {
      agents.value[index] = agent;
    }
    return agent;
  };

  const deleteAgent = async (id: string) => {
    // TODO: 实现删除智能体
    agents.value = agents.value.filter(agent => agent.id !== id);
  };

  return {
    agents,
    fetchAgents,
    createAgent,
    updateAgent,
    deleteAgent
  };
}); 